using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class admin_FeedbackDetails : admin_BaseUserControl
{
    FeedbackDAO daoFeedback = new FeedbackDAO();
    int id = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        ActiveAccording = "feedback";
        try
        {
            id = int.Parse(Request["id"]);
            Feedback fb = daoFeedback.GetFeedback(id);
            fb.Id = id;
            lblEmail.Text = fb.WriterEmail;
            lblDate.Text = fb.Date.ToShortDateString();
            lblSubject.Text = fb.Subject;
            txtContent.Text = fb.Content;
            chkIsReplied.Checked = fb.IsReplied;
        }
        catch (Exception ex)
        {
            ShowMessage("Error occured when trying to view feedback details. Please return back to feedback list page and try again");
        }
    }
    protected void lnkUpdate_Click(object sender, EventArgs e)
    {
        if (id == 0)
        {
            try
            {
                id = int.Parse(Request["id"]);
            }
            catch (Exception ex)
            {
                ShowMessage("Error occured when trying to update feedback state");
                return;
            }
        }
        if (daoFeedback.UpdateState(id, chkIsReplied.Checked) > 0)
        {
            ShowMessage("Feedback state is updated");
        }
        else ShowMessage("Error occured when trying to update feedback state");


    }
}
